//
//  ViewController.swift
//  MBBadges-Demo
//
//  Created by Trybst.Ma on 2021/5/14.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var mb_view: UIView!
    
    @IBOutlet weak var mb_button: UIButton!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        
        mb_view.badgeValue = "20"
        mb_view.badgeFont = UIFont.systemFont(ofSize: 11)
        
        
        mb_button.badgeValue = "99+"
        mb_button.badgeOriginX = mb_button.frame.width / 2 + 25
        
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        
        let digitNames = [
            0: "a", 1: "b", 2: "c", 3: "d"
        ]
        
        let numbers = [10333333332, 211111, 300001, 1222223]
        
        let strings = numbers.map { (num) -> String in
            
            var number = num
            var output = ""
            repeat {
                output = digitNames[number % 10]! + output
                number /= 10
            } while number > 0
            
            return output
            
        }
        
        
        var index = 20
        repeat {
            index += 2
            print(index)
        } while index < 40
        
        print(strings)
//        ["bac", "cb", "dab", "bd"]

    }
     
}

